package com.mitcub.panda.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mitcub.panda.entity.Admin;
import com.mitcub.panda.vo.AdminVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


/**
 * @项目名称: panda
 * @类名称: AdminMapper
 * @类描述: 系统管理员 Mapper 接口
 * @作者: tangloong
 * @创建时间: 2021/11/2 17:22
 */
public interface AdminMapper extends BaseMapper<Admin> {
    @Select("select * from sys_admin where username = #{username} limit 1")
    Admin selectByUsername(String username);

    //参数加上@Param(Constants.WRAPPER),xml里加上${ew.customSqlSegment}可以实现复杂条件检索查询
    @Select("select t1.*,t2.name as role_name,t3.name as dept_name from sys_admin t1 " +
            " LEFT JOIN sys_auth_group t2 ON t1.role_id = t2.id " +
            " LEFT JOIN sys_dept t3 ON t1.dept_id = t3.id " +
            " ${ew.customSqlSegment}")
    IPage<AdminVo> selectPageExt(Page<Admin> page, @Param(Constants.WRAPPER) Wrapper<Admin> wrapper);

}
